package game;

import player.Player;
import io.IOManager;

/**
 * Game Manager controls the logic between successive game's session
 * 
 * 
 * @version 2.2.0
 * 
 */
public class GameManager {

	private Player[] players;
	private IOManager ioManager;

	public GameManager() {
		this(new IOManager());  
	}

	public GameManager(IOManager ioManager) {
		players = new Player[3];
		this.ioManager = ioManager;

		players[0] = new Player("A", 0, ioManager);
		players[1] = new Player("B", 1, ioManager);
		players[2] = new Player("C", 2, ioManager);

	}

	/**
	 * Control to start the game process
	 */
	public void startGame() {
		boolean bEnd = false;
		Player lastWinner = null;

		do {
			Game game = new Game(players, ioManager, lastWinner);
			lastWinner = game.start();

			char input = ioManager.ioContinueGame(lastWinner.getName());
			bEnd = (input == 'n');
		} while (!bEnd);

		ioManager.ioEndApplicationMessage();
	}

}
